<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0">

    <title>登录</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="/images/favicon.ico">
    <link href="/css/bootstrap.min.css"
          rel="stylesheet">
    <link href="/css/font-awesome.css"
          rel="stylesheet">
    <link href="/css/animate.css"
          rel="stylesheet">
    <link href="/css/style.css"
          rel="stylesheet">
    <link href="/css/login.css"
          rel="stylesheet">
    <link
            href="/css/plugins/sweetalert/sweetalert.css"
            rel="stylesheet">

    <script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>

</head>

<body class="signin">
<div class="signinpanel">
    <div class="row">
        <div class="col-sm-7">
            <div class="signin-info">
                <div class="logopanel m-b">
                    <h1>[ Wan.com ]</h1>
                </div>
                <div class="m-b"></div>
                <h4>
                    欢迎进入 <strong> 后台管理网站</strong>
                </h4>
                <ul class="m-b">
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i>
                        权限分配、操作日志
                    </li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i>
                        访客记录、IP剔除
                    </li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i>
                        分页数据、动态图表
                    </li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 所有操作都异步</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i>
                        注：访问者无删除、修改操作
                    </li>
                </ul>
                <div class=" tooltip-demo ">
                    <strong>还没有账号？ <a href="#" style="color:rgba(252,246,242,0.99)"
                                      data-toggle="tooltip" data-placement="top" title="用户名： user  | 密码：123456">联系站长&raquo;</a>
                        <a href="/index"
                           style="color:#fffdf4;margin-left:15px;">首页&raquo;</a></strong>

                </div>
            </div>
        </div>
        <div class="col-sm-5">
            <form id="login" action="/login" method="post">
                <h3 class="no-margins">登录</h3>
                <p class="m-t-md">登录访问 Wan 后台管理网站</p>
                <input type="text" id="username" name="username" class="form-control uname"
                       placeholder="用户名"/> <input type="password" name="password" id="password"
                                                  class="form-control pword m-b" placeholder="密码"/>
                <span class="msg" style="color:#6722228a;margin-left:20px;"
                      href="javascript:void(0);"></span>
                <p><input id="remember" type="checkbox" value="ha" name="remember">记住密码</p>
                <button type="button" onclick="login()" class="btn btn-success btn-block">登录</button>
            </form>
        </div>
    </div>
    <div class="signup-footer">
        <div class="pull-left">
            <strong>&copy; 2020 Wan blog</strong>
        </div>
    </div>
</div>
<div class="gohome" style="display:none"></div>
<script src="/js/jquery.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/content.js"></script>
<script
        src="/js/plugins/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $(".gohome").css("display", "none");
    });
    $("#username").val('user')
    $("#password").val('123456')
    var login = function () {
        var username = $("#username").val().replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, "&quot;").replace(/'/g, "&#039;");
        var password = $("#password").val().replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, "&quot;").replace(/'/g, "&#039;");
        var remember = '';
        if ($("#remember").is(':checked')){
            remember = 'true';
        }else {
            remember = 'false';
        }
        var params = {
            username: username,
            password: password,
            remember: remember
        };
        $.ajax({
            url: 'login',
            type: 'post',
            data: params,
            dataType: 'json',
            success: function (data) {
                if (data.code == 200) {
                    swal({
                        title: '登录成功 :)',
                        text: ' 点击前往进入后台 ',
                        type: 'info',
                        showCancelButton: true,
                        confirmButtonColor: "#1c84c6",
                        confirmButtonText: "前往后台",
                        cancelButtonText: "回到主页",
                        timer: 8000,
                        closeOnConfirm: false,
                        closeOnCancel: false
                    }, function (isConfirm) {
                        if (isConfirm) {
                            window.location.href = "/admin/";
                            swal.close()
                        }else {
                            window.location.href = "/index";
                        }
                    });
                }
                if (data.code == 403){
                    swal({
                        title: "没有点击记住密码？",
                        text: "点击前往登录界面 ^-^",
                        type: "info",
                        confirmButtonColor: "#1c84c6",
                        showCancelButton: true,
                        confirmButtonText: "前往登录",
                        cancelButtonText: "回到首页",
                    }, function (isConfirm) {
                        if (isConfirm) {
                            swal.close()
                        }else {
                            window.location.href = "/index";
                        }
                        swal.close()
                    });
                }
                if (data.code == 500){
                    swal({
                        title: "登陆失败？",
                        text: data.msg,
                        type: "info",
                        confirmButtonColor: "#1c84c6",
                        showCancelButton: true,
                        confirmButtonText: "重新登录",
                        cancelButtonText: "返回主页",
                    }, function (isConfirm) {
                        if (isConfirm) {
                            swal.close()
                        }else {
                            window.location.href = "/index";
                        }
                        swal.close()
                    });
                }
            },
            error: function () {
                swal("登录错误，请重试。", "error");
            }
        });
    };
</script>
</body>

</html>